package com.shengwei.truck.driver.vm;
import androidx.lifecycle.MutableLiveData;
import com.shengwei.truck.driver.bean.JsonStatisticsYmdData;
import com.shengwei.truck.driver.bean.Result;

/**
 * 图表统计历史数据
 */
public class HistoryStatisticViewModel extends BaseHistoryViewModel {
    String TAG = "HistoryStatisticViewModel";
    private MutableLiveData<Result<JsonStatisticsYmdData>> mStatisticYear = new MutableLiveData<>();
    private MutableLiveData<Result<JsonStatisticsYmdData>> mStatisticMonth = new MutableLiveData<>();
    private MutableLiveData<Result<JsonStatisticsYmdData>> mStatisticWeek = new MutableLiveData<>();

    public HistoryStatisticViewModel() {
        super();
    }
    public MutableLiveData<Result<JsonStatisticsYmdData>> getStatisticYear() {
        return mStatisticYear;
    }
    public MutableLiveData<Result<JsonStatisticsYmdData>> getStatisticMonth() {
        return mStatisticMonth;
    }
    public MutableLiveData<Result<JsonStatisticsYmdData>> getStatisticWeek() {
        return mStatisticWeek;
    }
    /**
     * 按照 年，月，周统计数据
     * @param type：  0代表周;  1代表月;  2代表年
     * @param year：       type为1或2时传递
     * @param month:      type为1时传递
     * @param startTime : type为0时，传递周的开始时间
     * @param endTime:    type为0时，传递周的结束时间
     */
    public void getStatisticByYmd(int type,int year,int month,long startTime,long endTime){
        if(type == 0){
            mRepository.getStatisticByYmd(type,year,month,startTime,endTime,mStatisticWeek);
        }
        else if(type == 1){
            mRepository.getStatisticByYmd(type,year,month,startTime,endTime,mStatisticMonth);
        }
        else{
            mRepository.getStatisticByYmd(type,year,month,startTime,endTime,mStatisticYear);
        }
    }
}